<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css"  media="all">

</head>
<body>

<form class="layui-form" action="">
    <div class="layui-inline" style="margin: 30px 0 0 30px;">
        <div class="layui-input-inline">
            <select id="aa" name="modules" lay-verify="required" lay-search="" lay-filter="test1">
                <option th:each="item:${data}" th:value="${item.id}" >[[${item.title}]]</option>
            </select>
        </div>
    </div>
</form>
<div style="margin: 30px 0 0 30px;">
    <div id="test1" class="demo-tree demo-tree-box"></div>
</div>
<script src="/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script>
    layui.use(['form','element'], function() {
        var element = layui.element;
        var form = layui.form;
        form.render();
        form.on('select(test1)', function(data){
            $.ajax({
                url:"/resources/selectTree",
                data:{"id":data.value},
                type:"get",
                success:function(data){
                    console.log(data);
                    layui.use(['tree', 'util'], function(){
                        var tree = layui.tree,
                            layer = layui.layer,
                            util = layui.util
                        tree.render({
                            elem: '#test1' //默认是点击节点可进行收缩
                            ,data: data
                        });
                    });
                }
            });
        });
    });
</script>
</body>
</html>